/*
 * File:   StrategyConjunction.h
 * Author: root
 *
 * Created on November 16, 2008, 3:46 PM
 */

#ifndef _COLLECTIONEVALUATOR_H
#define	_COLLECTIONEVALUATOR_H

class CollectionEvaluator {
public:

    static bool evalConjunction(bool* decisions, int numDecisions) {
        bool ret = true;
        for (int i = 0; i < numDecisions; i++) {
            ret = ret && decisions[i];
            if (ret == false) {
                break;
            }
        }
        return ret;
    }

    static int majority(int* pickedCardArray, int arraySize) {
        int equivalenceClass[arraySize];
        for (int i = 0; i < arraySize; i++) {
            equivalenceClass[i] = 1;
        }
        int maxClassSize = 1;
        int maxClass = 0;
        for (int i = 0; i < arraySize; i++) {
            if (equivalenceClass[i] == 1) {
                for (int j = i+1; j < arraySize; j++) {
                    if (equivalenceClass[j] == 1) {
                        if (pickedCardArray[j] == pickedCardArray[i]) {
                            equivalenceClass[i]++;
                            equivalenceClass[j]++;
                            if (equivalenceClass[i] > maxClassSize) {
                                maxClass = i;
                                maxClassSize = equivalenceClass[i];
                            }
                        }
                    }
                }
            }
        }
        return pickedCardArray[maxClass];
    }

};

#endif	/* _COLLECTIONEVALUATOR_H */

